package com.nc.delivery_project.shared.locator;

import com.google.web.bindery.requestfactory.shared.Locator;
import com.nc.delivery_project.server.domain.Order;
import com.nc.delivery_project.server.service.OrderService;
import com.nc.delivery_project.shared.servicelocator.OrderServiceLocator;

/**
 * Created with IntelliJ IDEA.
 * User: Natalie D.
 * Date: 1/17/15
 * Time: 8:50 PM
 */
public class OrderLocator extends Locator<Order, Integer> {

    @Override
    public Order create(Class<? extends Order> clazz) {
        return new Order();
    }

    @Override
    public Order find(Class<? extends Order> clazz, Integer id) {
        return ((OrderService) new OrderServiceLocator().getInstance(null)).read(id);
    }

    @Override
    public Class<Order> getDomainType() {
        return Order.class;
    }

    @Override
    public Integer getId(Order domainObject) {
        return domainObject.getId();
    }

    @Override
    public Class<Integer> getIdType() {
        return Integer.class;
    }

    @Override
    public Object getVersion(Order domainObject) {

        return domainObject.getId();
    }
}
